import smtplib
#from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
import getopt
import sys
from email.Header import Header

class EmailMsg:
    def __init__(self, title, msg):
        self.title = title
        self.msg = msg

class Email:
    def __init__(self, login, passwd):
        self.login = login 
        self.passwd = passwd

    def send(self, to, mail):

        body_charset = 'UTF-8'

        msg = MIMEText(mail.msg, 'plain', body_charset)
        msg['From'] = self.login
        msg['To'] = to
        msg['Subject'] = Header(mail.title, 'UTF-8')

        mailServer = smtplib.SMTP("smtp.gmail.com", 587)
        mailServer.ehlo()
        mailServer.starttls()
        mailServer.ehlo()
        mailServer.login(self.login, self.passwd)
        mailServer.sendmail(self.login, to, msg.as_string())
        mailServer.close()


